package org.example;

import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;

/**
 *  模拟Callable获取值
 */
public class AppMyCallable {
    public static void main(String[] args) throws Exception {

        CountDownLatch countDownLatch = new CountDownLatch(1);

        MyRunnable<Integer> myRunnable = new MyRunnable<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("Callable中的call方法执行了,线程是:"+Thread.currentThread().getName());
                return 11;
            }
        },countDownLatch);

        new Thread(myRunnable).start();

        countDownLatch.await();

        System.out.println(myRunnable.getResult());
    }
}
